#!/usr/bin/python
# -*- coding: UTF-8 -*-

import tkinter as tk

# 创建窗体
window = tk.Tk()
window.title('Tk Demo')
window.geometry('350x500')

l = tk.Label(
    window,
    bg='yellow',
    width=20,
    text='empty'
)
l.pack()


def print_selection():
    if (val1.get() == 0) & (val2.get() == 0):
        l.config(text='both un-like')
    elif (val1.get() == 1) & (val2.get() == 0):
        l.config(text='like python')
    elif (val1.get() == 0) & (val2.get() == 1):
        l.config(text='like java')
    else:
        l.config(text='both like')


val1 = tk.IntVar()
c1 = tk.Checkbutton(
    window,
    text='python',
    variable=val1,
    onvalue=1,
    offvalue=0,
    command=print_selection
)
val2 = tk.IntVar()
c2 = tk.Checkbutton(
    window,
    text='java',
    variable=val2,
    onvalue=1,
    offvalue=0,
    command=print_selection
)
c1.pack()
c2.pack()

window.mainloop()

